<html xmlns:th="http://www.thymeleaf.org">
<style>
    .layui-form-item .layui-input-inline{
        width: 500px;
    }
    .layui-input {
        width: 90%;
        float:left;
    }
</style>
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
    <legend>修改密码</legend>
</fieldset>

<form class="layui-form" action="return false" lay-filter="formUpdate" onsubmit="return false">

    <div class="layui-form-item admin_hide">
        <div class="layui-inline">
            <label class="layui-form-label">原密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" lay-verify="password" autocomplete="off" class="layui-input"  />
            </div>
        </div>
    </div>


    <div class="layui-form-item admin_hide">
        <div class="layui-inline">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="pwd" lay-verify="password" autocomplete="off" class="layui-input"  />
            </div>
        </div>
    </div>
    <div class="layui-form-item admin_hide">
        <div class="layui-inline">
            <label class="layui-form-label">确认密码</label>
            <div class="layui-input-inline">
                <input type="password" name="pwdnew" lay-verify="passwordequest" autocomplete="off" class="layui-input" />
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="menu">立即修改</button>
        </div>
    </div>
</form>
<script th:inline="javascript">
    /* <![CDATA[*/
    layui.use(['upload','form', 'layedit', 'laydate','element'], function(){
        var form = layui.form;
        var layer = layui.layer;
        var element=layui.element;
        var URL = /*[[ ${#httpServletRequest.getContextPath()} ]]*/;
        //自定义验证规则
        form.verify({
            password:function(value,item){
                if( !/^[\S]{6,20}$/.test(value)){
                    return '密码长度范围是6-20';
                }
            }
            ,passwordequest:function(value ,item){
                if(value != $("[name='pwd']").val()){
                    return '两次密码不匹配';
                }
            }
        });

        //监听提交
        form.on('submit(menu)', function(data){

            ajaxUtil(URL+"/admin/adminuser/updatePwd",data.field,function(){
                layer.alert('操作成功，请重新登录？', function(index, layero){
                    layer.close(index);
                    window.location.href=URL+"/admin/login";
                });
            });
            return false;
        });

        form.render();

    });
    /* ]]> */
</script>
</html>